//
// Created by ubuntu on 2020/12/25.
//
#define LOG_TAG "fht"
#define LOG_VERBOSE "fht"

#include <vendor/hardware/bearpi/1.0/IBearPi.h>
#include <hidl/Status.h>
#include <log/log.h>
#include <android/log.h>



using vendor::hardware::bearpi::V1_0::BearPiAcquiredInfo;
using vendor::hardware::bearpi::V1_0::IBearPi;
using vendor::hardware::bearpi::V1_0::IBearPiClientCallback;
using android::sp;
using android::hardware::hidl_string;
using android::hardware::Return; // 命名空间
using android::hardware::Void;  // Void函数
using ::android::hardware::hidl_vec;


class BearPiClientCallback : public IBearPiClientCallback {
public:
      BearPiClientCallback() {}

      ~BearPiClientCallback() {}

      Return<void> onResult(uint64_t deviceId, const ::vendor::hardware::bearpi::V1_0::BearPiAcquiredInfo acquiredInfo,uint32_t vendorCode) override {
          ALOGD("onResult deviceid =%lu, vendorCode = %d, info = %d\n\n", deviceId, vendorCode, acquiredInfo);

          return Void();
      };

      Return<void> onGetAngleListener(float angle) override{
         ALOGD("onGetAngleListener = %f", angle);
         return Void();
      }

      Return<void> onAccelesAndGyroData(const hidl_vec<float>& acceles, const hidl_vec<float>& gyros) override{
        ALOGD(" onAccelesAndGyroData ");
        return Void();
      }

      Return<void> onAngleValue(float pitch, float roll, float yaw) override{
        return Void();
      }

      Return<int32_t> onCpuTemperature(float temp) override{
        return 0;
      }

};


int main() {
    sp <IBearPi> bear = IBearPi::getService();
    if (bear == nullptr) {
        ALOGE("Can't find IBearPi service ...");
        return -1;
    }

    ALOGD("IBearPi ON");
    sp <BearPiClientCallback> callback = new BearPiClientCallback();
    bear->setNotify(callback);
    bear->test();
    ALOGD("IBearPi end");
    sleep(1);
    return 0;
}

